package com.windrift.ws.order;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

import javax.xml.ws.Endpoint;

/**
 * Created by IntelliJ IDEA.
 * User: cy
 * Date: 10/05/12
 * Time: 9:25 PM
 * To change this template use File | Settings | File Templates.
 */
public class Server {
    protected Server() throws Exception {
//        System.out.println("Starting Server");
//        OrderProcessImpl orderProcessImpl = new OrderProcessImpl();
//        String address = "http://localhost:8080/OrderProcess";
//        Endpoint.publish(address, orderProcessImpl);
    }
    public static void main(String[] args) {
        try {
            Server server = new Server();
            server.anotherMethod();
            Thread.sleep(50000);
        } catch (Exception e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        System.exit(0);
    }

    public void anotherMethod () {
        OrderProcessImpl implementor = new OrderProcessImpl();
        JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setServiceClass(OrderProcess.class);
        svrFactory.setAddress("http://localhost:9000/OrderService");
        svrFactory.setServiceBean(implementor);
        svrFactory.getInInterceptors().add(new LoggingInInterceptor());
        svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
        svrFactory.create();
    }
}
